//
//  TestView.m
//  NeicunTest
//
//  Created by tanqilong on 16/5/24.
//  Copyright © 2016年 tanqilong. All rights reserved.
//

#import "TestView.h"
#import "NSTimer+TimerBlock.h"
#import "CADisplayLink+linkBlock.h"

@interface TestView ()
@property (nonatomic,strong) NSTimer * timer;
@property (nonatomic,strong) CADisplayLink * link;
@end

@implementation TestView

-(instancetype)initWithFrame:(CGRect)frame {
    self = [super initWithFrame:frame];
    if (self) {
        [self sayHello];
    }
    return self;
}

-(void)sayHello {
//    _timer = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(say) userInfo:nil repeats:YES];
//    [NSThread mainThread];
    
    
    __weak typeof(self) ws = self;
//    _timer = [NSTimer scheduledTimerWithTimeInterval:1 TimerDo:^{
//        [ws say];
//    }];
    
//    _link = [CADisplayLink displayLinkWithTarget:self selector:@selector(say)];
    _link = [CADisplayLink displayLinkWithblockDo:^{
        [ws say];
    }];
    
    self.link = [AFNETroking displayLinkWithblockDo:^{
        [self say];
    }];
//    [_link addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes];
}

-(void)timerIvalidate {
    [_timer invalidate];
}

-(void)say {
    NSLog(@"hello");
}

-(void)dealloc {
    NSLog(@"testView dealloc");
    [_timer invalidate];
    _timer = nil;
}


@end
